package com.bdqn.controller;

import com.bdqn.pojo.News;
import com.bdqn.pojo.Right;
import com.bdqn.service.NewsService;
import com.bdqn.service.RightService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * HelloController
 *
 * @author LILIBO
 * @since 2024/9/7
 */
@RestController
public class HelloController {

    @Resource
    private RightService rightService;

    @Resource
    private NewsService newsService;

    @RequestMapping("/hi")
    public Object hi() {
        List<Right> list = rightService.list();
        for (Right right : list) {
            System.out.println(right);
        }
        return list;
    }

    @GetMapping("/news/list")
    public Object newsList() {
        List<News> list = newsService.list();
        for (News news : list) {
            System.out.println(news);
        }
        return list;
    }

    /**
     * 删除新闻
     *
     * @param id
     * @return
     */
    @GetMapping("/news/del/{id}")
    public boolean newsDel(@PathVariable("id") Integer id) {
        return newsService.removeById(id);
    }

}
